package com.concurrent.execute.threadPool;

import java.util.concurrent.ThreadFactory;
import java.util.concurrent.atomic.AtomicInteger;

/**
 * 守护线程工厂
 * 
 * @author lkc
 *
 */
public class DaemonThreadFactory implements ThreadFactory {

	private final String THREAD_NAME = "deamon-pool-";
	AtomicInteger number = new AtomicInteger();

	@Override
	public Thread newThread(Runnable r) {
		Thread t = new Thread(r);
		t.setName(THREAD_NAME + number.getAndAdd(1));
		t.setDaemon(true);
		return t;
	}
}
